<?php
// the following variables are to be defined in "credentials.php":

$uname='***';
$dbname=$uname;
$DBhost='localhost';
$extmailhost='.';
$passwort='***';
$DBpasswort='***';
$band='Name of the Band';
$mailhome='mail.address@band-homepage.com';
$home='http://www.band-homepage.com';

include('credentials.php');

$gk=     array('G',     'B',    'S',        'R',      'A');
$gruppen=array('Gesang','Blech','Saxophone','Rythmus','Admin');
$wd=array("So","Mo","Di","Mi","Do","Fr","Sa");

for ($i=0,$grplegend='';$i<count($gruppen);$i++) $grplegend.='<b>'.$gk[$i].'</b>:'.$gruppen[$i].', ';
$grplegend.=' <b>t</b>utti=<b>'.substr(join('',$gk),0,-1).'</b>';
$tu=count($gk)-1;$tut=(1<<$tu)-1;
function getgrp($chk){global $_POST,$gruppen,$gk,$tut;
 if (isset($_POST[$chk])) {for($i=0,$grp=0;$i<count($gruppen);$i++) $grp+=$_POST[$gruppen[$i]];}
 if ($grp==0) { // in case no groups have been selected (initial state)--> select all groups as default
   for($grp=$tut,$_POST[alle]=1,$i=0;$i<count($gruppen);$i++) $_POST[$gruppen[$i]]=1;
 }
 return $grp;
}
function strgrp($s) {global $gruppen,$gk,$tut;$ret=0;$s=strtoupper($s);
 for ($i=0;$i<strlen($s);$i++) for($j=0;$j<count($gruppen);$j++) if ($s[$i]==$gk[$j]) {
   $ret+=1<<$j;
   break;
 }
 if (strchr($s,'T')) $ret=$ret|$tut; // tutti ...
 return $ret;
}
function grpstr($grp) {global $gruppen,$gk,$tu,$tut; $s='';
 for($i=0;$i<$tu;$i++) if ((1<<$i)&$grp) $s.=$gk[$i];
 if (($grp&$tut)==$tut) $s='tutti';
 if ($grp&($tut+1)) $s.=(strlen($s)?'+':'').'A';
 return $s;
}
function datum($s,$sep=' ',$t=''){global $wd;$ts=strtotime($s);$da=getdate($ts);
if (is_array($sep)) list($sep,$sep1)=$sep; else $sep1=$sep;
 return $wd[$da[wday]].$sep.substr($s,8) . "." . substr($s,5,2)
        .(empty($t)?'':$sep1.substr($t,0,5)) ;
}
function cbp($n,$v='j',$shw=1){global $_POST;return cb($n,$v,$_POST[$n],$shw);}
function cb($n,$v='j',$chk='get_from_n',$shw=1){global $$n;
  if ($chk=='get_from_n') $chk=$$n;
  return "<input type=checkbox name='$n' value='$v'".($chk=='j' || $chk>0?' checked ':'')
    .(strlen($shw)>1?$shw:'').">".($shw?' '.str_replace ('[]','',$n).' ':'')."\n";
}
function einlog($needpw){
if ($needpw)
   echo "<br>Bitte Bandpasswort eingeben: <input type=\"password\""
       ."name=\"password\" value=\"\" size=10>"
       ."<input type=\"Submit\" value=\"login\">"
       ."<script language=JavaScript>document.f.password.focus()</script>";
else
   echo "<input type=\"hidden\" name=\"password\" value=\"$_POST[password]\">";
return $needpw;
}
mysql_connect($DBhost,$uname,$DBpasswort) or die("ein Zugang als $uname!");
mysql_select_db($dbname) or die("Datenbank $dbname nicht OK!");

$r=mysql_fetch_row(mysql_query("SHOW COLUMNS FROM members LIKE 'instrument'"));
$instrlegend='<b>'.eregi_replace(',',', ',eregi_replace('.*\(|\).*|\'','',$r[1])).'</b>';
$r=mysql_fetch_row(mysql_query("SHOW COLUMNS FROM datmem LIKE 'state'"));
$states=eregi_replace('.*\(|\).*|\'','',$r[1]);
$loggedin=($_POST[password]==$passwort);
?>